<template>
  <div class="headerView">
    <div class="header_right">
      <img style="height: 5rem" src="../../../assets/images/vegetables.png" alt="" />
      <div>
        <div class="title">莱阳润丰食品有限公司</div>
        <div class="title_6">Laiyang Runfeng Foodstuff Co., Ltd</div>
        <div class="title_3">山东省莱阳市万第镇赤山村</div>
        <div class="title_6">Chishan Village. Wandi Town. Laiyang City. Yantai City. Shandong Province. P.R.China</div>
      </div>
    </div>
    <div class="phone">
      <img src="../../../assets/images/phonecall.png" alt="" />
      <span class="phoneNum">0535-7750678</span>
    </div>
  </div>
  <!-- 导航条 -->
  <div class="navbar">
    <el-menu
      :default-active="activeIndex"
      text-color="#2A8555"
      active-text-color="#2A8555"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
    >
      <div class="navItem" v-for="(item, index) in navs" :key="index">
        <el-menu-item v-if="!item.showSub" :index="index + ''">{{ item.title }}</el-menu-item>
        <el-sub-menu v-else :index="index + ''">
          <template #title>{{ item.title }}</template>
          <el-menu-item v-for="(sub, subIndex) in item.subs" :index="subIndex + ''" :key="subIndex">{{
            sub.title
          }}</el-menu-item>
        </el-sub-menu>
      </div>
    </el-menu>
  </div>
</template>

<script>
import { reactive, toRefs } from "@vue/reactivity";
import { useRouter } from "vue-router";

export default {
  setup() {
    const router = useRouter();
    const status = reactive({
      activeIndex: "1",
      navs: [
        { title: "网站首页", showSub: false },
        { title: "关于我们", showSub: false, subs: [{ title: "公司简介" }] },
        { title: "产品展示", showSub: false, subs: [{ title: "产品二级" }] },
        { title: "公司实力", showSub: false },
        { title: "联系我们", showSub: false },
      ],
    });

    const handleSelect = (key, keyPath) => {
      console.log(key, keyPath);
      if (key == 0) {
        //网站首页
        router.push("/web-home");
      } else if (key == 4) {
        //联系我们
        router.push("/contact/us");
      } else if (key == 1) { 
        //公司简介
        router.push("/intro/message");
      } else if (key == 2) { 
        //产品介绍
        router.push("/product");
      } else if (key == 3) { 
        //公司实力
        router.push("/web-home");
      }
    };

    return {
      ...toRefs(status),
      handleSelect,
    };
  },
};
</script>

<style lang="less" scoped>
.headerView {
  background: url("../../../assets/images/header_bg.jpeg") no-repeat top center;
  background-size: 100% 100%;
  width: 100%;
  height: 10rem;
  display: flex;
  justify-content: space-around;
  align-items: center;

  .header_right {
    display: flex;
    align-items: center;
  }
  .title {
    color: #333;
    font-size: 3rem;
    font-weight: 600;
    margin-left: 1rem;
  }
  .title_3 {
    .title_com(#333)
  }

  .title_6 {
    .title_com(#666)
  }
  .title_com(@color) {
    color: @color;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 1rem;
  }
  .phone {
    display: flex;
    justify-content: space-around;
    align-items: center;
    img {
      width: 4rem;
    }
    .phoneNum {
      color: var(--rf-primary-color);
      font-size: 3rem;
      font-weight: 600;
      margin-left: 1rem;
    }
  }
}

.navbar {
  width: 100%;
  height: 3.6rem;
  background-color: #eee;
  background-color: var(--rf-primary-color);
  color: #eee;
  .navItem {
    height: 100%;
    width: 7rem;
    line-height: 3rem;
    text-align: center;
  }

  // :focus-visible {
  //   outline: none;
  // }
}

// .el-dropdown-link {
//   display: inline-block !important;
//   width: 100%;
//   height: 100%;
//   line-height: 3rem;
// }
</style>
